package cn.shuo.app.db.ext;

import cn.shuo.app.db.mapper.AQuestionMapper;
import cn.shuo.app.db.model.AQuestion;
import cn.shuo.app.model.AQuestionUser;
import org.apache.ibatis.annotations.Select;

import java.util.List;

public interface AQuestionExtMapper extends AQuestionMapper {

    @Select("SELECT * FROM aquestion where board_id = #{board_id} ")
    List<AQuestion> selectList(int board_id);

//
//    @Select("SELECT l.*,r.name as username ,r.avatar_url as avatar FROM aquestion l left join user r on l.user_id = r.account_id \n" +
//            "where  board_id =  #{board_id}  limit #{start},#{end}")
//    List<AQuestionUser> selectAqUserList(int board_id,int start ,int end);

    @Select("SELECT q.*,b.book_name,b.img_url,r.name as username,r.avatar_url as avatar FROM  (aquestion q left join abook b on q.book_id= b.id )  LEFT JOIN user r\n" +
            "    on q.user_id = r.account_id\n" +
            "    where q.board_id = #{board_id} ")
    List<AQuestionUser> selectAqUserList(int board_id);

}
